package com.bianmaba.examples.controller.authorization.user;

import com.bianmaba.examples.bean.authorization.User;
import com.bianmaba.examples.service.authorization.user.IUserService;
import com.bianmaba.spring.mvc.controller.ReadController;
import com.bianmaba.spring.mvc.method.support.annotations.JSON;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = {"authorization/user"})
public class UserController extends ReadController<User, String> {

    @Autowired
    private IUserService service;

    @Override
    protected IUserService getService() {
        return service;
    }

    @JSON
    @RequestMapping({"/get_by_username"})
    public User getByUsername(String username) {
        User result = this.getService().findByUsername(username);
        return result;
    }

}
